home *** CD-ROM | disk | FTP | other *** search
- unit MoveU;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, Buttons, ExtCtrls;
-
- type
- TForm1 = class(TForm)
- Label1: TLabel;
- Button1: TButton;
- ListBox1: TListBox;
- GroupBox1: TGroupBox;
- BitBtn1: TBitBtn;
- SpeedButton1: TSpeedButton;
- procedure GenericMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.GenericMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- type
- TBoolStrings = array[Boolean] of String;
- const
- Vert: TBoolStrings = ('Bottom', 'Top');
- Horz: TBoolStrings = ('right', 'left');
- var
- Pt: TPoint;
- begin
- Pt := Point(X, Y);
- Pt := Form1.ScreenToClient((Sender as TControl).ClientToScreen(Pt));
- with Pt do
- Caption := Format('%s %s (%d,%d)',
- [Vert[Y < ClientHeight div 2],
- Horz[X < ClientWidth div 2],
- X, Y]);
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- var
- Loop: Integer;
- begin
- for Loop := 0 to ComponentCount - 1 do
- if Components[Loop] is TControl then
- TButton(Components[Loop]).OnMouseMove := GenericMouseMove
- end;
-
- end.
-